unit CadastroHistorico;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, StdCtrls, Buttons, ExtCtrls, DB, DBTables, Mask,
  DBCtrls, DBClient, Provider, Menus, ComCtrls, Grids, DBGrids, ToolEdit,
  CurrEdit, RXDBCtrl;

type
  TFCadastroHistorico = class(TFormCadastro)
    Label14: TLabel;
    Label1: TLabel;
    DBENome: TDBEdit;
    QCadastroHIST_CODIGO: TIntegerField;
    QCadastroHIST_DESCRICAO: TStringField;
    QCadastroDATAMODIFICACAO: TDateTimeField;
    QCadastroUSUARIO: TStringField;
    QCadastroUSUARIO_CADASTRO: TStringField;
    QCadastroUSUARIO_AUTERACAO: TStringField;
    QCadastroUSUARIO_EXCLUSAO: TStringField;
    QCadastroDATA_CADASTRO: TDateTimeField;
    QCadastroDATA_EXCLUSAO: TDateTimeField;
    QCadastroDATA_AUTERACAO: TDateTimeField;
    QCadastroEXCLUIDO: TStringField;
    QCadastroUSUARIO_RECUPERACAO: TStringField;
    QCadastroDATA_RECUPERACAO: TDateTimeField;
    cdsCadastroHIST_CODIGO: TIntegerField;
    cdsCadastroHIST_DESCRICAO: TStringField;
    cdsCadastroDATAMODIFICACAO: TDateTimeField;
    cdsCadastroUSUARIO: TStringField;
    cdsCadastroUSUARIO_CADASTRO: TStringField;
    cdsCadastroUSUARIO_AUTERACAO: TStringField;
    cdsCadastroUSUARIO_EXCLUSAO: TStringField;
    cdsCadastroDATA_CADASTRO: TDateTimeField;
    cdsCadastroDATA_EXCLUSAO: TDateTimeField;
    cdsCadastroDATA_AUTERACAO: TDateTimeField;
    cdsCadastroEXCLUIDO: TStringField;
    cdsCadastroUSUARIO_RECUPERACAO: TStringField;
    cdsCadastroDATA_RECUPERACAO: TDateTimeField;
    RxDBHistCodigo: TRxDBCalcEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure BtnIncluirClick(Sender: TObject);
    procedure BtnEditarClick(Sender: TObject);
    procedure BtnExcluirClick(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
    procedure QCadastroBeforePost(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCadastroHistorico: TFCadastroHistorico;

implementation

uses UGeral;

{$R *.dfm}

procedure TFCadastroHistorico.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 FCadastroHistorico:=nil;
  inherited;
end;

procedure TFCadastroHistorico.FormCreate(Sender: TObject);
begin
  QCadastro.SQl.Clear;
  QCadastro.SQl.Add('SELECT * FROM HISTORICO');
 inherited;
end;

procedure TFCadastroHistorico.BtnIncluirClick(Sender: TObject);
begin

  inherited;
  DBENome.SetFocus;

end;

procedure TFCadastroHistorico.BtnEditarClick(Sender: TObject);
begin

  if DsCadastro.DataSet.IsEmpty then
   begin
    ShowMessage('Tabela esta vazia !');
    exit;
   end;

  inherited;
  DBENome.SetFocus;

end;

procedure TFCadastroHistorico.BtnExcluirClick(Sender: TObject);
begin
  if MessageDlg('Deseja realmente excluir este Historico ? ',mtWarning,mbOKCancel,0) = 2 then
   exit;

  inherited;

end;

procedure TFCadastroHistorico.BtnSalvarClick(Sender: TObject);
begin

  if DBENome.Text = '' then
  begin
   ShowMessage('Campo Nome tem que ser preenchido !');
   exit;
  end;

  inherited;
end;

procedure TFCadastroHistorico.QCadastroBeforePost(DataSet: TDataSet);
begin
  inherited;
  DataSet.FieldByName('USUARIO').AsString:=Usuario;
  DataSet.FieldByName('DATAMODIFICACAO').AsDateTime:=Date;
end;

end.
